package com.epoint.configuration;

import com.epoint.handlerinterceptor.LoginHandlerInterceptor;
import com.epoint.messageconverter.EpointMessageConverter;
import org.springframework.context.annotation.Configuration;
import org.springframework.http.converter.HttpMessageConverter;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

import java.util.List;

@Configuration
public class WebMvcSelfConfiguration implements WebMvcConfigurer {

    @Override
    public void extendMessageConverters(List<HttpMessageConverter<?>> converters) {
        converters.add(new EpointMessageConverter());
    }

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        // 添加自己的拦截器
        registry.addInterceptor(new LoginHandlerInterceptor()).addPathPatterns("/**")
            .excludePathPatterns("/", "/login.html", "/topasslogin")
            .excludePathPatterns("/css/**", "/js/**", "/fonts/**", "/images/**");
    }
}
